package com.fc.im.netty;

import com.fc.im.netty.codec.MessageDecoder;
import com.fc.im.netty.codec.MessageEncoder;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.timeout.ReadTimeoutHandler;

import java.util.concurrent.TimeUnit;

/**
 * Created by ChanJiabo on 2017/1/14.
 */
public class IMChannelInitializer extends ChannelInitializer<SocketChannel>{


    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        ch.pipeline().addLast(new ChannelManagerHandler());
        ch.pipeline().addLast(new MessageDecoder());
        ch.pipeline().addLast(new MessageEncoder());
        ch.pipeline().addLast(new ReadTimeoutHandler(5, TimeUnit.MINUTES));
        ch.pipeline().addLast(new ServerMessageHandler());


    }
}
